Project of Seattle Airbnb

Questions:

1. What is the average price of the Airbnbs in Seattle?

2. Which variable have the stongest correlation to the price of an Airbnb?

3. Which price range has the most number of Airbnb?

In [1]:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

Prepare the dataset

In [2]:
calender = pd.read_csv("calendar.csv")
listings = pd.read_csv("listings.csv")
reviews = pd.read_csv("reviews.csv")
In [3]:
calender.head()
Out[3]:
listing_id date available price
0 241032 2016-01-04 t $85.00
1 241032 2016-01-05 t $85.00
2 241032 2016-01-06 f NaN
3 241032 2016-01-07 f NaN
4 241032 2016-01-08 f NaN
In [4]:
listings.head()
Out[4]:
id listing_url scrape_id last_scraped name summary space description experiences_offered neighborhood_overview ... review_scores_value requires_license license jurisdiction_names instant_bookable cancellation_policy require_guest_profile_picture require_guest_phone_verification calculated_host_listings_count reviews_per_month
0 241032 https://www.airbnb.com/rooms/241032 20160104002432 2016-01-04 Stylish Queen Anne Apartment NaN Make your self at home in this charming one-be... Make your self at home in this charming one-be... none NaN ... 10.0 f NaN WASHINGTON f moderate f f 2 4.07
1 953595 https://www.airbnb.com/rooms/953595 20160104002432 2016-01-04 Bright & Airy Queen Anne Apartment Chemically sensitive? We've removed the irrita... Beautiful, hypoallergenic apartment in an extr... Chemically sensitive? We've removed the irrita... none Queen Anne is a wonderful, truly functional vi... ... 10.0 f NaN WASHINGTON f strict t t 6 1.48
2 3308979 https://www.airbnb.com/rooms/3308979 20160104002432 2016-01-04 New Modern House-Amazing water view New modern house built in 2013. Spectacular s... Our house is modern, light and fresh with a wa... New modern house built in 2013. Spectacular s... none Upper Queen Anne is a charming neighborhood fu... ... 10.0 f NaN WASHINGTON f strict f f 2 1.15
3 7421966 https://www.airbnb.com/rooms/7421966 20160104002432 2016-01-04 Queen Anne Chateau A charming apartment that sits atop Queen Anne... NaN A charming apartment that sits atop Queen Anne... none NaN ... NaN f NaN WASHINGTON f flexible f f 1 NaN
4 278830 https://www.airbnb.com/rooms/278830 20160104002432 2016-01-04 Charming craftsman 3 bdm house Cozy family craftman house in beautiful neighb... Cozy family craftman house in beautiful neighb... Cozy family craftman house in beautiful neighb... none We are in the beautiful neighborhood of Queen ... ... 9.0 f NaN WASHINGTON f strict f f 1 0.89

5 rows × 92 columns

In [5]:
reviews.head()
Out[5]:
listing_id id date reviewer_id reviewer_name comments
0 7202016 38917982 2015-07-19 28943674 Bianca Cute and cozy place. Perfect location to every...
1 7202016 39087409 2015-07-20 32440555 Frank Kelly has a great room in a very central locat...
2 7202016 39820030 2015-07-26 37722850 Ian Very spacious apartment, and in a great neighb...
3 7202016 40813543 2015-08-02 33671805 George Close to Seattle Center and all it has to offe...
4 7202016 41986501 2015-08-10 34959538 Ming Kelly was a great host and very accommodating ...
In [6]:
df1 = pd.merge(calender, listings, left_on='listing_id', right_on='id', how='left').drop('id', axis=1)
In [7]:
df1 = df1.fillna(-1)
In [8]:
df1.head()
Out[8]:
listing_id date available price_x listing_url scrape_id last_scraped name summary space ... review_scores_value requires_license license jurisdiction_names instant_bookable cancellation_policy require_guest_profile_picture require_guest_phone_verification calculated_host_listings_count reviews_per_month
0 241032 2016-01-04 t $85.00 https://www.airbnb.com/rooms/241032 20160104002432 2016-01-04 Stylish Queen Anne Apartment -1 Make your self at home in this charming one-be... ... 10.0 f -1.0 WASHINGTON f moderate f f 2 4.07
1 241032 2016-01-05 t $85.00 https://www.airbnb.com/rooms/241032 20160104002432 2016-01-04 Stylish Queen Anne Apartment -1 Make your self at home in this charming one-be... ... 10.0 f -1.0 WASHINGTON f moderate f f 2 4.07
2 241032 2016-01-06 f -1 https://www.airbnb.com/rooms/241032 20160104002432 2016-01-04 Stylish Queen Anne Apartment -1 Make your self at home in this charming one-be... ... 10.0 f -1.0 WASHINGTON f moderate f f 2 4.07
3 241032 2016-01-07 f -1 https://www.airbnb.com/rooms/241032 20160104002432 2016-01-04 Stylish Queen Anne Apartment -1 Make your self at home in this charming one-be... ... 10.0 f -1.0 WASHINGTON f moderate f f 2 4.07
4 241032 2016-01-08 f -1 https://www.airbnb.com/rooms/241032 20160104002432 2016-01-04 Stylish Queen Anne Apartment -1 Make your self at home in this charming one-be... ... 10.0 f -1.0 WASHINGTON f moderate f f 2 4.07

5 rows × 95 columns

1. What is the average price of the Airbnbs in Seattle?

In [16]:
import plotly.offline as py
import plotly.express as px
import plotly.graph_objects as go
import plotly.offline as pyo
from plotly.subplots import make_subplots
import seaborn as sns
from statistics import mean
In [18]:
prices = [i for i in df1['price_x'] if not -1]

for i in list(df1['price_y']):
    if i != -1:
        prices.append(i)
In [33]:
price = []

for i in prices:
    i = i[:-2]
    i = ''.join(e for e in i if e.isalnum())
    price.append(int(i))
In [38]:
average = mean(price)
In [39]:
average
Out[39]:
127.97616553169199
In [ ]:
trace = go.Box(y=price, name='Price')

data = [trace]

layout = go.Layout(title='Boxplot of Price', hovermode='x')

fig = go.Figure(data=data, layout=layout)

fig.show()

It is easy to see that the averge price of Aribnb in Seattle is $127.98

2. Which variable have the stongest correlation to the price of an Airbnb?

In [40]:
fig=plt.figure(figsize=(12,8), dpi= 100, facecolor='w', edgecolor='k')
M0 = sns.heatmap(df1.corr(), annot = True).set_title('Airbnb Seattle corresponding correlation')

Based on the color of the heatmap. It is easy to see that all varibles related to reviews and availability. host_listings_count have very strong correlation to the price of an Airbnb.

3. Which price range has the most number of Airbnb?

In [42]:
fig = px.histogram(price)
fig.show()

So it is clearly to see that most of the price of airbnbs are between 35 to 175 and 150 has the most number of airbnbs

In [ ]: